﻿@model IEnumerable<Contract.Business.Entity.BEConsulta>

@{
    ViewBag.Title = "Agendar";
    Layout = "~/Views/Shared/_Layout.cshtml";
    short diaDaSemana = (short)DateTime.Today.DayOfWeek;
    DateTime dataInicial = DateTime.Today.AddDays(-diaDaSemana);
}

<h2>Consultas</h2>

<p>
    @Html.ActionLink("Nova Consulta", "Create")
</p>
<table class="table">
    <tr>
        <th>
            Domingo
        </th>
        <th>
            Segunda
        </th>
        <th>
            Terça
        </th>
        <th>
            Quarta
        </th>
        <th>
            Quinta
        </th>
        <th>
            Sexta
        </th>
        <th>
            Sábado
        </th>
    </tr>

    <tr>
        @for (int i = 0; i < 7; i++)
        {
            <td>
                <center><strong>@dataInicial.ToShortDateString()</strong></center>
                <br />
                @{
            dataInicial = dataInicial.AddDays(1);
            int hora = 7;
            int proximaHora;
            int minutos = 1;
            int proximosMinutos;

            for (int j = 0; j < 20; j++)
            {
                hora += (j % 2 == 1 ? 0 : 1);
                if (minutos == 0)
                {
                    minutos = 30;
                    proximaHora = hora + 1;
                    proximosMinutos = 0;
                }
                else
                {
                    minutos = 0;
                    proximaHora = hora;
                    proximosMinutos = 30;
                }

                @Html.Raw(string.Format("{0}:{1} às {2}:{3}", hora.ToString().PadLeft(2, '0'), minutos.ToString().PadLeft(2, '0'), proximaHora.ToString().PadLeft(2, '0'), proximosMinutos.ToString().PadLeft(2, '0')));
                    <br />
            }
                }
            </td>
        }
    </tr>

    <tr>
        @for (int i = 0; i < 7; i++)
        {
            <td>
                @dataInicial.ToShortDateString()
                @{dataInicial = dataInicial.AddDays(1);}
            </td>
        }
    </tr>
</table>
